From ec7b1f72082194f7b5b032658ef020a7217e4372 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 17 Feb 2023 11:33:44 +0000 Subject: [PATCH] ci: Add no-cache option to run-docker.sh script Use `run-docker.sh build --no-cache` to discard the cached layers if you need to rebuild the image without modifying the Dockerfile. --- .gitlab-ci/run-docker.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index c911e6afe1..6574a4f4af 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -23,6 +23,7 @@ push=0 list=0 print_help=0 no_login=0 +no_cache=0 while (($# > 0)); do case "${1%%=*}" in @@ -34,6 +35,7 @@ while (($# > 0)); do --base|-b) read_arg base "$@" || shift;; --version|-v) read_arg base_version "$@" || shift;; --no-login) no_login=1;; + --no-cache) no_cache=1;; *) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;; esac shift @@ -103,11 +105,21 @@ TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}" if [ $build == 1 ]; then echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}" - ${CMD} build \ - ${format} \ - --build-arg HOST_USER_ID="$UID" \ - --tag "${TAG}" \ - --file "${base}.Dockerfile" . + if [ $no_cache == 0 ]; then + ${CMD} build \ + ${format} \ + --build-arg HOST_USER_ID="$UID" \ + --tag "${TAG}" \ + --file "${base}.Dockerfile" . + else + ${CMD} build \ + ${format} \ + --no-cache \ + --build-arg HOST_USER_ID="$UID" \ + --tag "${TAG}" \ + --file "${base}.Dockerfile" . + fi + exit $? fi -- 2.30.2